<?php

/**
 * project actions.
 *
 * @package    anchor
 * @subpackage project
 * @author     Your name here
 * @version    SVN: $Id: actions.class.php 23810 2009-11-12 11:07:44Z Kris.Wallsmith $
 */
class projectActions extends myActions
{
	/**
	 * Method to display default project page
	 * @param sfWebRequest $request
	 */
	public function executeIndex(sfWebRequest $request)
	{
		
    // Define acceptable filters
    $filters 								= array ();
    $filters["all"] 				= "allActiveProjects";
    $filters["new"] 				= "newActiveProjects";
    $filters["cottage"]			= "cottageActiveProjects";
    $filters["wooden"] 			= "woodenActiveProjects";
    $filters["premium"]			= "premiumActiveProjects";                
    $filters["multifloor"]	= "multifloorActiveProjects";
        
    // Get filter value
    $filter = $request->getParameter('filter', null);
		// Check for needed filter
		if(is_null($filter) or !array_key_exists($filter, $filters))
			$this->redirect("@projectfilter?module=project&action=index&filter=new&page=");
					
		// Display grid
		$this->pager = new sfDoctrinePager('project', sfConfig::get('app_project_list_count'));
		$this->pager->setTableMethod($filters[$filter]);		
		$this->pager->setPage($request->getParameter('page', 1));
		$this->pager->init();
	}
	/**
	 * Method to display project example
	 * @param sfWebRequest $request
	 */
	public function executeShow(sfWebRequest $request)
	{
		$this->project = Doctrine::getTable("project")->getProjectExample($request->getParameter('id', null));
	}
}
